package cn.liu.jetpack_demo.routes

import android.util.Log
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import cn.liu.jetpack_demo.models.BottomBar
import cn.liu.jetpack_demo.pages.DetailPage
import cn.liu.jetpack_demo.pages.HomePage
import cn.liu.jetpack_demo.pages.ProfilePage
import cn.liu.jetpack_demo.pages.SettingsPage
import cn.liu.jetpack_demo.pages.user.list.UserListPage

@ExperimentalMaterial3Api
@Composable
fun setupNavGraph(
  navController: NavHostController
) {
  NavHost(navController = navController, startDestination = Screen.Home.route) {
    composable(route = BottomBar.Home.route) {
      HomePage(navController = navController)
    }
    composable(route = BottomBar.Profile.route) {
      ProfilePage(navController = navController)
    }
    composable(route = BottomBar.Setting.route) {
      SettingsPage(navController = navController)
    }
    composable(route = Screen.Detail.route, arguments = listOf(navArgument("id") {
      type = NavType.IntType
    },
      navArgument("name") {
        type = NavType.StringType
      }
    )) {
      Log.d("Args", it.arguments?.getInt("id").toString())
      Log.d("Args", it.arguments?.getString("name").toString())
      DetailPage(navController = navController)
    }
    composable(route = Screen.UserList.route) {
      UserListPage(navController = navController)
    }
  }

}